<?php

namespace App\Console\Commands;

use App\Models\StoreOrder;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class OrderControl extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'OrderControl';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $time=strtotime(date('Y-m-d h:i:s'));
        $orderData=StoreOrder::get();
        foreach ($orderData as $v){
            if ($time-$v['add_time']>300){
                $upOrder=StoreOrder::where('status', 1)
                    ->update(['status'=>6]);
                Log::info($upOrder,[date('Y-m-d h:i:s')]);
            };
        }
    }
}
